package com.demo12;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class CollectionDemo {
    public static void main(String[] args) {
        //多态的方式定义一个集合的基本信息，定义一个学生的基本对象信息
        List<Students> list = new ArrayList<Students>();

        //实例化学生类
        Students students1 = new Students("令狐冲",20);
        Students students2 = new Students("张无忌",22);
        Students students3 = new Students("乔峰",30);

        list.add(students1);
        list.add(students2);
        list.add(students3);

        Iterator<Students> iterator = list.iterator();

        while (iterator.hasNext()){
            Students stu = iterator.next();

            System.out.println(stu.getName()+":"+stu.getAge());
        }
    }
}
